<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.bothin.experiment4.constant.EmployeeTypeConstant" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <%@include file="../component/head_link_css_js.jsp"%>

    <style>
        .layui-form-item .layui-input-inline{
            width: 280px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部区域 -->
    <%@include file="../component/nav_header.jsp"%>
    <!-- 侧边菜单 -->
    <jsp:include page="../component/nav_side_menu.jsp">
        <jsp:param name="nav" value="2#2" />
    </jsp:include>

    <!-- 内容主体区域 -->
    <div class="layui-body" id="LAY_app_body" style="top: 50px;">
        <div class="layui-fluid">
            <div class="layui-card">
                <div class="layui-card-header layuiadmin-card-header-auto">
                    <form action="${pageContext.request.contextPath}/employee/stockman/list">
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-useradmin employee_add" data-type="add" type="button">添加</button>
                        </div>
                        <div class="layui-inline">
                            <div class="layui-input-block">
                                <input type="text" name="keyword" placeholder="请输入工号/名字查找" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn layuiadmin-btn-admin" type="submit">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-body" style="padding-bottom: 50px;">
                    <table class="layui-table">
                        <colgroup>
                            <col width="200">
                            <col>
                            <col>
                            <col>
                            <col width="180">
                        </colgroup>
                        <thead>
                        <tr>
                            <th>
                                销售工号
                                <span class="layui-table-sort layui-inline" ><i class="layui-edge layui-table-sort-asc" title="升序"></i><i class="layui-edge layui-table-sort-desc" title="降序"></i></span>
                            </th>
                            <th>名字</th>
                            <th>电话</th>
                            <th>密码</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${pageInfo.list}" var="item">
                            <tr>
                                <td>${item.account}</td>
                                <td>${item.name}</td>
                                <td>${item.phone}</td>
                                <td>${item.password}</td>
                                <td>
                                    <button type="button" class="layui-btn layui-btn-sm employee_add" data-eid="${item.employeeId}">
                                        <i class="layui-icon">&#xe642;</i>
                                        修改
                                    </button>
                                    <a type="button" class="layui-btn layui-btn-sm layui-btn-danger"
                                            <c:if test="${item.usable==EmployeeTypeConstant.USABLE}" var="flag">
                                                href="${pageContext.request.contextPath}/employee/stockman/delete?employeeId=${item.employeeId}&page=${pageInfo.pageNum}">
                                                <i class="layui-icon">&#xe640;</i> 删除
                                            </c:if>
                                            <c:if test="${not flag}">
                                                href="${pageContext.request.contextPath}/employee/stockman/delete?employeeId=${item.employeeId}&page=${pageInfo.pageNum}">
                                                <i class="layui-icon">&#xe608;</i> 恢复
                                            </c:if>
                                    </a>
                                </td>
                            </tr>
                        </c:forEach>

                        </tbody>
                    </table>
                    <div class="layui-btn-group" style="position: absolute;right: 14px;margin-top: 10px;">
                        <a type="button" class="layui-btn layui-btn-primary layui-btn-sm ${pageInfo.hasPreviousPage!=true?"layui-btn-disabled":''}"
                           href="${pageContext.request.contextPath}/employee/stockman/list?page=${pageInfo.pageNum-1}${key}"
                        >
                            <i class="layui-icon">&#xe603;</i>
                        </a>
                        <c:forEach var="i" begin="1" end="${pageInfo.pages}">
                            <a type="button" class="layui-btn layui-btn-${pageInfo.pageNum==i?"normal":"primary"} layui-btn-sm"
                               href="${pageContext.request.contextPath}/employee/stockman/list?page=${i}${key}">${i}</a>
                        </c:forEach>
                        <a type="button" class="layui-btn layui-btn-primary layui-btn-sm ${pageInfo.hasNextPage!=true?"layui-btn-disabled":''}"
                           href="${pageContext.request.contextPath}/employee/stockman/list?page=${pageInfo.pageNum+1}${key}"
                        >
                            <i class="layui-icon">&#xe602;</i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div id="hide_form_content" style="display: none">

</div>
</body>
</html>
<script>
    layui.config({
        base: '${pageContext.request.contextPath}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table','sample','useradmin','layer','form'], function(){

        var $ = layui.$
            ,form = layui.form
            ,table = layui.table,layer=layui.layer;

        $('.employee_add').on('click', function(){
            var eid = $(this).data('eid');
            var url = "${pageContext.request.contextPath}/employee/stockman/to/add";
            if (eid!=undefined)
                url += "?employeeId="+eid+"&page=${pageInfo.pageNum}";
            $("#hide_form_content").load(url);

            layer.open({
                type: 1
                ,title: '添加用户'
                ,content: $("#hide_form_content")
                ,area: ['435px', '300px']
                ,shadeClose:true
            });
        });
    });
</script>


